// 知识库相关

import { AxiosProgressEvent, CancelToken } from 'axios'

export interface IKnowledgeBase {
  knowledge_base_name: string
  kb_info: string
  in_db: boolean
}

export interface ICreateKBParams {
  knowledge_base_name: string
  kb_info: string
}
export interface IDelKBParams {
  knowledge_base_name: string
}
// 是否存在源文件 0-不存在 1-存在
export enum InFolder {
  YES = 1,
  NO = 0
}
// 是否存在向量库 0-不存在 1-存在 2-正在向量化
export enum InDB {
  NO = 0,
  YES = 1,
  LOADING = 2
}
export interface IGetKBFileParams {
  knowledge_base_name: string
}
export interface IKBFile {
  no: number
  file_name: string
  document_loader: string
  text_splitter: string
  docs_count: number
  in_folder: InFolder
  in_db: InDB
}
export interface IDelFileParams {
  knowledge_base_name: string
  file_names: string[]
  delete_content: boolean // true代表同时删除源文件和向量  false代表只删除向量
}
export interface IUploadKBFileParams {
  knowledge_base_name: string
  override: string
  to_vector_store: string
  chunk_size: string
  chunk_overlap: string
  zh_title_enhance: string
  not_refresh_vs_cache: string
  files: File[]
}
export interface IUpdateFilesParams {
  knowledge_base_name: string
  files: string[]
}
export interface IKnowledgeBaserApi {
  createKB: (params: ICreateKBParams) => Promise<void>
  updateKBInfo: (params: ICreateKBParams) => Promise<void>
  getKnowledgeBaseList: () => Promise<IKnowledgeBase[]>
  deleteKB: (params: IDelKBParams) => Promise<void>
  deleteFile: (params: IDelFileParams) => Promise<void>
  getKBFilesList: (params: IGetKBFileParams) => Promise<IKBFile[]>
  uploadKBFile: (
    params: FormData,
    onUploadProgress?: (progressEvent: AxiosProgressEvent) => void,
    signal?: AbortSignal
  ) => Promise<void>
  updateFiles: (params: IUpdateFilesParams) => Promise<void>
}
